package com.kingtone.rongji;

import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class OrderSummitSuccessActivity  extends BaseActivity {

	private TextView title = null;
	private ImageView backBtn = null;
	private ImageView leftIcon = null;
	private TextView rightTitle = null;
	
	//应付金额
	private TextView successCount = null;
	//付款方式
	private TextView successPayMethod = null;
	
	private Button checkBtn = null;
	private double payAmount = 0.0;
	private String orderNo = null;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_order_summit_success);
		Intent intent = getIntent();
		if(intent.hasExtra("payAmount"))
		{
			payAmount = intent.getDoubleExtra("payAmount", 0.0);
		}
		if(intent.hasExtra("orderNo"))
		{
			orderNo = intent.getStringExtra("orderNo");
		}
		setupView();
	}
	
	private void setupView()
	{
		title = (TextView)findViewById(R.id.title);
		title.setText(getString(R.string.order_summit_success_title));
		backBtn = (ImageView)findViewById(R.id.back);
		backBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				//onBackPressed();
				finish();
				Intent intent = new Intent(OrderSummitSuccessActivity.this, MainActivity.class);
				startActivity(intent);
			}
		});
		
		leftIcon = (ImageView)findViewById(R.id.left_icon);
		leftIcon.setBackgroundResource(R.drawable.icon_de);
		
		rightTitle = (TextView)findViewById(R.id.right_title);
		rightTitle.setVisibility(View.INVISIBLE);
		
		successCount = (TextView)findViewById(R.id.order_summit_success_count);
		successCount.setText(Html.fromHtml(getString(R.string.order_summit_success_count) +"<font color='#FF6C1F'>" + payAmount + "</font>"));
		
		successPayMethod = (TextView)findViewById(R.id.order_summit_success_pay_method);
		successPayMethod.setText(Html.fromHtml(getString(R.string.order_summit_success_pay_method) +"<font color='#01A5CB'>鲜享卡货到付款</font>"));
		
		checkBtn= (Button)findViewById(R.id.order_summit_success_check_order);
		checkBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(OrderSummitSuccessActivity.this, OrderDetailActivity.class);
				intent.putExtra("orderNum", orderNo);
				startActivity(intent);
			}
		});
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent event) { // 监听物理键
		
		if (keyCode == KeyEvent.KEYCODE_BACK) {// 返回键
			finish();
			Intent intent = new Intent(OrderSummitSuccessActivity.this, MainActivity.class);
			startActivity(intent);
		}
		return true;
	}
}
